<?php
	

    $dsn = 'mysql:dbname=php10-7;host=127.0.0.1';
    $pdo = new PDO($dsn,'root','');

    //$sql = "insert into `test` (`username`,`content`) values ('123','用户名')";
    //$sth = $pdo->prepare($sql);
    //$sth->execute();
    
    /**$sql = "select * from test";
    $sth = $pdo->prepare($sql);
    $sth->execute();

    $data = $sth->fetchAll();
    var_dump($data);
    var_dump($data[0]['username']);
    */
    function write($pdo,$sql){
        $sth = $pdo->prepare($sql);
        return $sth->execute();
    }

    function read($pdo,$sql){
        $sth = $pdo->prepare($sql);
        $sth->execute();
        $rows = $sth->fetchAll();
        return $rows;
    }


?>